//
//  Main_CollectWatch_WX_VC.m
//  ZITHER
//
//  Created by weixin on 2019/2/18.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Main_CollectWatch_WX_VC.h"
#import "MainScrollTbv.h"
#import "GoodsModel.h"


@interface Main_CollectWatch_WX_VC ()
@property (nonatomic,strong)MainScrollTbv * tbv2;//追踪

@end

@implementation Main_CollectWatch_WX_VC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.baseNavigationView NavigationBarStyle:1];
    self.baseNavigationView.leftButton1.hidden = YES;
    [self.baseNavigationView setHiddenNav:NO VC:self];
    self.baseNavigationView.navViewStyle.title.text = @"我的追踪";
    
    // Do any additional setup after loading the view.
    [self.view addSubview:self.tbv2];
    [self.tbv2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(NaviHeight);
    }];
}

-(void)reloadData{
    
    [[serviceDefualt loadgetFollowGoodspage:self.tbv2.page reponseObjctClass:nil]subscribeNext:^(ResponseData *x) {
        if (x.success) {
            NSArray *arr = x.responseRawData[@"data"];
            if (self.tbv2.page == 0) {
                self.tbv2.arrMSource[2] = [[NSMutableArray alloc]init];
            }
            if (arr.count ==0) {
                if (self.tbv2.page != 0) {
                    [self.tbv2.mj_footer endRefreshingWithNoMoreData];
                    return ;
                }
                
            }else{
                for (NSDictionary *dic in arr) {
                    FollowGoodsModel *model = [FollowGoodsModel yy_modelWithJSON:dic];
                    [self.tbv2.arrMSource[2] addObject:model];
                }
            }
            [self.tbv2.mj_header endRefreshing];
            [self.tbv2.mj_footer endRefreshing];
            [self.tbv2 reloadData];

        }else{
            [Tools showTips:x.errorInfo];
        }
        
    }];
     
}






-(MainScrollTbv *)tbv2{
    if (!_tbv2) {
        _tbv2 = [[MainScrollTbv alloc]initWithFrame:CGRectMake( kScreenW*2, 0 , kScreenW, kScreenH-kStatusBarHeight-100-50-kBottomSafeHeight+70)];
        _tbv2.index = 1;
        __weak __typeof(self)weakSelf = self;
        _tbv2.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
            self.tbv2.page ++;
            [weakSelf reloadData];
        }];
        _tbv2.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            self.tbv2.page = 0;
            [weakSelf reloadData];
        }];
        [_tbv2.mj_header beginRefreshing];
    }
    return _tbv2;
}

@end
